<template>
  <div class="page-container">
    <el-form :model="dataForm" ref="dataForm" label-width="200px">
      <el-form-item prop="max_integral_day" maxlength="10" label="每日获取积分上限：" :rules="[{ required: true, message: '请输入每日获取积分上限', trigger: 'blur' }]"  show-word-limit clearable>
        <el-input v-model="dataForm.max_integral_day" style="width:600px"></el-input>
        <label>积分</label>
      </el-form-item>
      <div style="padding-top: 10px;">
        <el-form-item>
          <el-button type="primary" @click="submitForm('dataForm')"
            >提交</el-button
          >
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import CyTable from "@/views/Core/CyTable";
import KtButton from "@/views/Core/KtButton";
import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
import { format } from "@/utils/datetime";
import utils from "@/assets/js/utils.js";
export default {
  components: {
    PopupTreeInput,
    CyTable,
    KtButton,
    TableColumnFilterDialog
  },
  data() {
    return {
      dataForm: {
        max_integral_day: ""
      }
    };
  },

  methods: {
    getSysConfigInfoById: function() {
      let this_ = this;
      this.utils.request.getSysConfigInfoById({'id':25}, function(res) {
        console.log(res.data.val);
        this_.dataForm.max_integral_day = res.data.val;
      });
    },
    // 编辑
    submitForm: function() {
      this.$refs.dataForm.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            let this_ = this;
            var reg = /^[1-9]\d*$/;
            if(!reg.test(this.dataForm.max_integral_day)){
              this_.$message({ message: "请输入1-10位正整数", type: "error" });
              return;
            }
            if(this.dataForm.max_integral_day>9999999999){
              this_.$message({ message: "请输入1-10位正整数", type: "error" });
              return;
            }
            let params = Object.assign({}, this.dataForm);
            params.t = "sysConfig";
            params.val = this.dataForm.max_integral_day;
            params.id = 25;
            this.utils.request.updateSysConfigInfo(params, function(res) {
              this_.$message({ message: "操作成功", type: "success" });
            });
          });
        }
      });
    }
  },
  mounted() {
	  this.getSysConfigInfoById();
  }
};
</script>

<style scoped>
</style>